<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame"%>
  <head>
	<title>公共平台 </title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<!-- 样式文件的引入 -->
	<script type="text/javascript">
     var requestUrl="http://${basePath}:${port}${ctx}/business/projectmanage/leader/establishInput?projectId=${project.id}&r="+new Date().getTime();
	</script>
</head>
<body>
	<form action="${ctx}/business/projectmanage/leader/establishsave" method="post"  enctype="multipart/form-data" id="addProjectsDataForm">
		<%-- <input type="hidden" value="${rows }" name="rows" id="rows"> --%>
		<input type="hidden" name="len" id="len">
		<input type="hidden" name="id" id="id" value="${project.id }">
		<input type="hidden" name="noteText" id="noteText" value="${project.noteText }">
		<input type="hidden" name="responseFile" id="responseFile" value="${project.responseFile }">
		<input type="hidden" name="budgetMenuData" id="budgetMenuData" value=""/>
		<div id="file" align="center"   class="easyui-layout">
			<h1>网上竞价文件</h1>
			<hr />
			<div class="easyui-panel" data-options="border:true,title:'基本信息'" style="padding:6px;margin-bottom: 6px">
				<table class="infoTable" style="margin-top: 0px;width:100%">
					<tr>
						<th class="key" text-align:left>项目名称：</th>
						<td colspan="3">${project.name}</td>
					</tr>
					<tr>
						<th class="key" width="10%" text-align:left>项目编码：</th>
						<td width="40%">${project.code}</td>
						<th class="key" width="10%" align="left">项目类型：</th>
						<td width="40%">${project.catagoryName }</td>
					</tr>
					<tr>
						<th class="key" align="left">采购内容：</th>
						<td colspan="3">${project.buyContent}</td>
					</tr>
					<tr>
						<th class="key" align="left">采购人：</th>
						<td>${project.operater}</td>
						<th class="key" align="left">委托单位：</th>
						<td>${project.agentName}</td>
					</tr>
					
					<tr>
						<th class="key" align="left">项目负责人姓名：</th>
						<td>${project.manageName}</td>
					<th class="key">项目预算(元)：</th>
						<td>
							<fmt:formatNumber value="${project.budgetAmount}" type="currency" pattern=".00#"/>
						</td>	
					</tr>
					
					<tr>
						<th class="key" align="left">付款方式：</th>
						<td>${project.payType}</td>
					<th class="key">采购单位：</th>
						<td>${project.buyName}</td>	
					</tr>
			</table>
			</div>
				
				<c:if test="${project.status==26}">
					<div class="easyui-panel" data-options="border:true,title:'项目基本要求'" style="padding:6px;margin-bottom: 6px">
						<table class="infoTable">	
							<tr>
								<th class="key" > 回复信息：</th>
					            <td>
					            	<textarea rows="5" cols="75" id="replyContent" name="replyContent"  ></textarea>
					            </td>
							</tr>
						</table>
					</div>
				</c:if>
				
			<div class="easyui-panel" data-options="border:true,title:'项目基本要求'" style="padding:6px;margin-bottom: 6px">	
			<table class="infoTable">	
				<tr>
					<th class="key" > 建设地点：</th>
		            <td>
		            	<input type="text"  class="easyui-validatebox" data-options="required:true" name="deliveryPoint" value="${project.deliveryPoint }"/>
		            </td>
		            <th class="key">工程工期：</th>
					<td>
						<input type="text"  class="easyui-validatebox" data-options="required:true,validType:['positiveInteger']" name="timeLimit" value="${project.timeLimit }"/> 个日历天
					</td>
					</td>
				</tr>
				
				<tr>
				<!-- 
					<th class="key" cosplan="2">联合体投标：</th>
					<td>
						<input type="radio"  class="textField" name="isUnit"  value="false" ${project.isUnit==false||project.isUnit==null?"checked":"" } /> 不允许
						<input type="radio"  class="textField" name="isUnit" value="true" ${project.isUnit==true?"checked":"" }/> 允许
					</td>
				 -->
					<th class="key">投标人保证金金额(元)：</th>
					<td cosplan="3">
						<input type="text"  class="easyui-validatebox" data-options="required:true,validType:['priceDecimal']"  name="promissMoney" value="<fmt:formatNumber value="${project.promissMoney }" type="currency" pattern=".00#"/>" />
					</td>
						
				</tr>
				<tr>
					<th class="key" > 项目负责人房间号：</th>
		            <td>
		            	<input type="text"  class="easyui-validatebox" data-options="required:true" name="manageRoom" value="${project.manageRoom}"/>
		            </td>
		            <th class="key">项目负责人电话：</th>
					<td>
						<input type="text" class="easyui-validatebox"  data-options="required:true" name="managerTel" value="${project.managerTel }"/>
					</td>
				</tr>
				<tr>
					<th class="key" > 计价方式：</th>
		            <td>
		            	<input type="radio"  class="textField" name="caluType" id="caluType1"  value="1" ${project.caluType==1||project.caluType==null?"checked":"" } /><label for="caluType1"> 工程量清单综合单价报价法 </label>&nbsp;
						<input type="radio"  class="textField" name="caluType" id="caluType2" value="2" ${project.caluType==2?"checked":"" }/><label for="caluType2"> 全费用综合单价</label>
		            </td>
		            <th class="key" > 质保期：</th>
		            <td>
		            	<input type="text"  class="easyui-validatebox" data-options="required:true,validType:['positiveInteger']" name="qualityYears" value="${project.qualityYears}"/> 年
		            </td>
				</tr>
			</table>	
		</div>
		
		<div class="easyui-panel" data-options="border:true,title:'投标人资格'" style="padding:6px;margin-bottom: 6px">	
		<table   class="infoTable">	
				<tr>
					<th class="key">竞标人资质等级要求：</th>
					<td>
						<textarea style="height:80px;" rows="5" cols="75" id="biderLevelRequire" name="biderLevelRequire"  
						 oninput="checkLength('biderLevelRequireRemarkError',100,'biderLevelRequire')" onpropertychange="checkLength('biderLevelRequireRemarkError',100,'biderLevelRequire')" onkeyup="checkLength('biderLevelRequireRemarkError',100,'biderLevelRequire')">${project.biderLevelRequire}</textarea>
						 <font color="red"><br />注：100个字符以内，还可以输入<span class="input_font" id="biderLevelRequireRemarkError">100</span>个字符</font>
					</td>
				</tr>
				<tr>
					<th class="key">竞标人项目经理资格等级要求：</th>
					<td>
						<textarea style="height:80px;" rows="5" cols="75" id="biderManagerRequire" name="biderManagerRequire"  
						 oninput="checkLength('biderManagerRequireRemarkError',100,'biderManagerRequire')" onpropertychange="checkLength('biderManagerRequireRemarkError',100,'biderManagerRequire')" onkeyup="checkLength('biderManagerRequireRemarkError',100,'biderManagerRequire')">${project.biderManagerRequire}</textarea>
						 <font color="red"><br />注：100个字符以内，还可以输入<span class="input_font" id="biderManagerRequireRemarkError">100</span>个字符</font>
					</td>
				</tr>
				<tr>
					<th class="key">投标单位授权代表社保缴纳时间：</th>
					<td>
						<input name="socialSecurityBeginTimeStr" editable="false"  id="socialSecurityBeginTime" data-options="required:true" value="${project.socialSecurityBeginTime }">-<input name="socialSecurityEndTimeStr" id="socialSecurityEndTime" editable="false"  data-options="required:true" value="${project.socialSecurityEndTime }">
					</td>
				</tr>
				<tr>
				<th  class="key">其他资格要求：</td>
					<td>
						<textarea  style="height:80px;" rows="5" cols="75" id="othereRequire" name="othereRequire"  
						oninput="checkLength('othereRequireRemarkError',200,'othereRequire')" onpropertychange="checkLength('othereRequireRemarkError',200,'othereRequire')" onkeyup="checkLength('othereRequireRemarkError',200,'othereRequire')">${project.othereRequire}</textarea>
						<font color="red"><br />注：200个字符以内，还可以输入<span class="input_font" id="othereRequireRemarkError">200</span>个字符</font>
					</td>
				</tr>
				
		</table>	
		</div>
		
		
		<div class="easyui-panel" data-options="border:true,title:'其他要求'" style="padding:6px;margin-bottom: 6px">	
				<table class="infoTable">	
					<tr>
						<th class="key" >  推荐品牌：</th>
			            <td>
			            	<textarea class="easyui-validatebox"  style="height:80px;" rows="1" cols="75" id="recommendBrand" name="recommendBrand"  
							 oninput="checkLength('recommendBrandRemarkError',100,'recommendBrand')" onpropertychange="checkLength('recommendBrandRemarkError',100,'recommendBrand')" onkeyup="checkLength('recommendBrandRemarkError',100,'recommendBrand')">${project.recommendBrand}</textarea>
							 <font color="red"><br />注：100个字符以内，还可以输入<span class="input_font" id="recommendBrandRemarkError">100</span>个字符</font>
			            </td>
					</tr>
					<tr>
						<th class="key">  注意事项：</th>
						<td>
							<textarea style="height:80px;" rows="1" cols="75" id="remind" name="remind"  
							 oninput="checkLength('remindRemarkError',100,'remind')" onpropertychange="checkLength('remindRemarkError',100,'remind')" onkeyup="checkLength('remindRemarkError',100,'remind')">${project.remind}</textarea>
							 <font color="red"><br />注：100个字符以内，还可以输入<span class="input_font" id="remindRemarkError">100</span>个字符</font>
						</td>
					</tr>
				</table>	
			</div>
	
	
	<div class="easyui-panel" data-options="border:true,title:'评标设置'" style="padding:6px;margin-bottom: 6px">
			<table  class="infoTable">
				<tr>
					<th class="key" >采购人确认时间：</td>
					<td ><input class="easyui-datetimebox"  editable="false" data-options="required:true,validType:['dateTimeMoreCurrentCompare','isWorkDayToValidTime[\'${ctx }\']']" name="validTime" id="validTime" value="${project.validTime==null?buyerSureTime:project.validTime }"/></td>
					<th class="key" cosplan="2">开标日期：</td>
					<td cosplan="2" id="bidStartDateTr"><input type="text" class="easyui-datebox" editable="false"  name="bidStartDateStr" id="bidStartDateStr" value="${project.bidStartTime }" data-options="required:true"/>-
					<select name='bidStartTimeStr' id="bidStartTimeStr" class="easyui-combobox" style="width:50px" data-options="required:true,validType:['isOpenBidPro[\'${ctx }\',\'${dataset.evaluateRooms }\']','isWorkDay[\'${ctx }\']'<c:if test="${dataset.bidOpeningInTheMonAm==true}"></c:if><c:if test="${dataset.bidOpeningInTheMonAm==false}">,'isMonAm'</c:if>]">
						<option value='09' ${project.bidStartTime.getHours()==09?"selected='selected'":""}>09</option>
						<option value='15' ${project.bidStartTime.getHours()==15?"selected='selected'":""}>15</option>
						</select>点 <font color="red">注：非工作日不允许设置项目开标</font>
					</td>
				</tr>
				<tr>
					<th class="key">报价方式：</td>
					<td>
						<input type="radio" name='bidType' value="0" ${project.bidType==0||project.bidType==null?"checked":"" }/>金额  &nbsp;&nbsp;
						<input type="radio" name='bidType' value="1" ${project.bidType==1?"checked":"" }/>费率
					</td>
					<th class="key">原开标项目：</td>
					<td>
						<input style="width:150px;" class="easyui-validatebox"  name="parentProjCode"  id="parentProjCode" value="${project.parentProjCode }">
					</td>
				</tr>
			</table>
			</div>


		<div class="easyui-panel" data-options="border:true,title:'工程需求'" style="padding:6px;margin-bottom: 6px">
					<table class="infoTable">
						<tbody>
							<tr>
							<th align="right" width="15%">工程需求：</th>
							<td style="border-right: none" width="35%">
								<div id="fileQueue" style="margin: 10px 0px 0px 10px">
									<input type="file" name="uploadify" id="uploadify" data-options="required:true"/>
									<p style="color: #aaaaaa;width: auto">
						1、按住Ctrl可选择多个文件上传;<br/>
						2、可上传*.rar;*.zip;*.doc;*.docx;*.xls;*.xlsx;*.jpg;*.png;*.gif;*.bmp;*.pdf;*.dwg;*.DXF;*.DWT;*.dws类型文件<br/>
						</p>
								</div>
							</td>
							<td style="border-left: none" colspan="2">
								<c:forEach items="${resList}" var="res">
									<c:if test="${res.functionFlog==8}">
										<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);">${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
									</c:if>
								</c:forEach>
							</td>
						</tr>
						</tbody>
					</table>		
			</div>
					
			<!-- <div class="easyui-panel" data-options="border:true,title:'采购需求前注'" style="padding:6px;margin-bottom: 6px">			
						<table  class="infoTable"  id="tab2" border="1" width="60%" align="center"
							style="margin-top: 20px"  >
							
							<tr>
							<th>序号：</th>
								<th cosplan="3" style='text-align: center'>前注文本</th>
							    <th style='text-align: center'>操作</th>
							    <td>
							    	<a href="javascript:void(0);" id="but2" class="easyui-linkbutton" iconCls="icon-add" plain="true">增加前缀文本</a>
							    </thd
							</tr>
			
							
						</table>
				</div> -->
		
		
		
		<div class="easyui-panel" data-options="border:true,title:'响应文件资料清单'" style="padding:6px;margin-bottom: 6px">				
			<table   class="infoTable"     id="tab4" border="1" width="60%" align="center"
				style="margin-top: 20px"   >
				
				<tr>
				<th style='text-align: center'>序号：</th>
				<th style='text-align: center'>资料名称：</th>
					<!-- <th style='text-align: center'>提交方式：</th>
				    <th style='text-align: center'>操作：</th>
				    <th>
				   	 	<a href="javascript:void(0);" id="but4" class="easyui-linkbutton" iconCls="icon-add" plain="true">增加资料</a>
				    ：</th> -->
				</tr>

				
			</table>
			
		</div>
		
		
		<div align="center" style="margin-top: 25px;margin-bottom: 20px">
			<a href="javascript:void(0);" id="generateWorld"  class="easyui-linkbutton" iconCls="icon-chart" plain="true"><strong>生成Word</strong></a>
			<a class="easyui-linkbutton" id="establishFile" href="javascript:void(0);">无</a><br/>
		</div>
		</div>
	</form>
</body>

<script >
		$(function(){
			//parent.$('#saveEntityBt').hide();
			var resIds = "";
			<c:forEach items="${resList}" var="res">
			resIds += ",${res.id}";
			</c:forEach>
			
			//初始化生成world按钮旁的竞价文件预览
			var bidFileId="";
			var bidFileName="无";
			<c:forEach items="${resList}" var="res">
			<c:if test="${res.functionFlog==5}">
				bidFileId="${res.id}";
				bidFileName="${res.oldName}";
			</c:if>
			</c:forEach>
			//$("#establishFile").attr("href","${ctx}/business/projectmanage/fileView?resId="+bidFileId);
			$("#establishFile").attr("href","javascript:showOpenFile('ctx','"+bidFileId+"',"+requestUrl+");");
			$("#establishFile").html(bidFileName);
			
			
			$('#budgetMenuData').val(resIds);
			//年月控件
			$("#socialSecurityBeginTime,#socialSecurityEndTime").datebox({  
	            formatter: function(date) {  
	                var y = date.getFullYear();  
	                var m = date.getMonth() + 1;  
	                return y + '-' + (m < 10 ? ('0' + m) : m);  
	            },  
	            parser: function(s) {  
	                if (!s) {  
	                    return new Date();  
	                }  
	                var ss = s.split('-');  
	                var y = parseInt(ss[0], 10);  
	                var m = parseInt(ss[1], 10);  
	                if (!isNaN(y) && !isNaN(m)) {  
	                    return new Date(y, m - 1);  
	                } else {  
	                    return new Date();  
	                }  
	            }  
	        }); 

			//初始化前注文本信息
			 var noteText=$("#noteText").val();
	       //alert("note: "+noteText);
	       $.each(noteText.split("@"),function(index,data){
		       if(data!=""){
			       var _len =index+3;
					$("#len2").val(_len + 1); 
			       $("#tab2")
					.append(
							"<tr id="+_len+" align='center'>"
							+ "<td>"
							+ _len
							+ "</td>"
							+ "<td class='key' ><textarea rows='5' cols='75' class='noteText' id='pretext"+_len+"' name='pretext'"+_len+ "data-options='required:true' >"+data+"</textarea></td>"
							+ "<td><a href=\'#\' onclick=\'deltr2("
							+ _len
							+ ")\'>删除</a></td>"
							+ "</tr>");
			   }
		   });

	     //初始化响应文件信息
	       var responseFile=$("#responseFile").val();
	       //alert("note: "+noteText);
	       $.each(responseFile.split("@"),function(index,data){
		       if(data!=""){
		    	   var _len = $("#tab4 tr").length;
				   $("#len4").val(_len + 1); 
					$("#tab4").append(
						"<tr id="+_len+" align='center'>"
						+ "<td width='15%'>"
						+ _len
						+ "</td>"
						//+ "<td class='key'><input type='text' class='responseFile easyui-validatebox' style='width:380px;'  name='data"+_len+"' id='data"+_len+"' value='"+data.replace("-","")+"'/></td>"
						+"<td class='key' align='left' width='85%' style='padding-left:30px;'>"
						+ "<textarea rows='3' cols='90' class='responseFile' name='data"+_len+"' id='data"+_len+"' oninput=\"checkLength('remarkError"+_len+"',100,'data"+_len+"')\" "
						+ "onpropertychange=\"checkLength('remarkError"+_len+"',100,'data"+_len+"')\" onkeyup=\"checkLength('remarkError"+_len+"',100,'data"+_len+"')\">"+data.replace("-","")+"</textarea>"
						+ "<font color='red'><br />注：100个字符以内，还可以输入<span class='input_font' id='remarkError"+_len+"'>50</span>个字符</font>"
						+"</td>"
						//+ "<td class='key'><input type='text' name='method"+_len+"' id='method"+_len+"' /></td>"
						//+ "<td><a href=\'#\' onclick=\'deltr4("
						//+ _len
						//+ ")\'>删除</a></td>"
						+ "</tr>");
			   }
		   });


	       //===================绑定点击事件
			//增加前缀文本
			$("#but2").click(function() {
				var _len = $("#tab2 tr").length - 1+3;
				$("#len2").val(_len + 1); 
				$("#tab2")
						.append(
								"<tr id="+_len+" align='center'>"
								+ "<td>"
								+ _len
								+ "</td>"
								+ "<td class='key' ><textarea rows='5' cols='75' class='noteText' id='pretext"+_len+"' name='pretext'"+_len+ "data-options='required:true' ></textarea></td>"
								+ "<td><a href=\'#\' onclick=\'deltr2("
								+ _len
								+ ")\'>删除</a></td>"
								+ "</tr>");

			});	

		       
	       //增加响应资料名称
			$("#but4").click(function() {
				var _len = 1;//$("#tab4 tr").length - 1+10;
				if(parseInt(_len)>=12){
					top.$.messager.alert("提示",'响应文件资料最多只能添加两条!');
					return;
				}
				   $("#len4").val(_len + 1); 
				$("#tab4").append(
						"<tr id="+_len+" align='center'>"
						+ "<td>"
						+ _len
						+ "</td>"
						+ "<td class='key'><input type='text' class='responseFile' name='data"+_len+"' id='data"+_len+"' /></td>"
						//+ "<td class='key'><input type='text' name='method"+_len+"' id='method"+_len+"' /></td>"
						+ "<td><a href=\'#\' onclick=\'deltr4("
						+ _len
						+ ")\'>删除</a></td>"
						+ "</tr>");
			});


			
		});


		//删除前缀文本<tr/>
		var deltr2 = function(index) {
			var _len = $("#tab2 tr").length+3;
			/* $("#len2").val(_len-2); */
			$("#tab2 tr[id='" + index + "']").remove();//删除当前行
			for (var i = index + 1, j = _len; i < j; i++) {
				var pretext = $("#pretext" + i).val();
				//alert(i+":"+pretext);
				$("#tab2 tr[id=\'" + i + "\']").replaceWith(
						"<tr id=" + (i - 1) + " align='center'>" + "<td>" + (i - 1)
						+ "<td class='key' ><textarea rows='5' cols='75' class='noteText' id='pretext"+(i - 1)+ "' value='" + pretext +"' name='pretext"+(i - 1)+ "'data-options='required:true' >" + pretext +"</textarea></td>"
						+ "<td><a href=\'#\' onclick=\'deltr2("
						+ (i - 1) + ")\'>删除</a></td>" + "</tr>");
			}
		}


		//删除资料名称
		var deltr4 = function(index) {
			var _len = $("#tab4 tr").length+12;
			$("#len2").val(_len-2);
			$("#tab4 tr[id='" + index + "']").remove();//删除当前行
			for (var i = index + 1, j = _len; i < j; i++) {
				var data = $("#data" + i).val();
				var method = $("#method" + i).val();
				$("#tab4 tr[id=\'" + i + "\']").replaceWith(
						"<tr id=" + (i - 1) + " align='center'>" + "<td>" + (i - 1)
						//+ "<td><input type='text' name='method" + (i - 1)
						//+ "' value='" + method + "' id='method" + (i - 1)
						//+ "'/></td>" 
						+ "<td><input type='text' class='responseFile' name='data" + (i - 1)
						+ "' value='" + data + "' id='data" + (i - 1)
						+ "'/></td>" 
						+ "<td><a href=\'#\' onclick=\'deltr4("
						+ (i - 1) + ")\'>删除</a></td>" + "</tr>");
	}
			
		}	

		//生成world文档
		$("#generateWorld").click(function(){
			//alert(2);
			var id=$("#id").val();
			//alert(id);
				if(!top.$('#addProjectsDataForm').form('validate')){//表单校验是否通过
					$.messager.alert('提示',"请将信息填写完整或检查信息填写是否正确后点击生成Word!",'error',function(){});
					return;
				}
				//前注文本
				var noteText="";
				$('.noteText').each(function(){
					noteText+=$(this).val()+"@";
				});
				$("#noteText").val(noteText);

				//响应文件
				var responseFile="";
				$('.responseFile').each(function(){
					var val=$.trim($(this).val());
					if(val==""){
						val="-";
					}
					responseFile+=val+"@";
				});
				$("#responseFile").val(responseFile);
				
			 $.ajax({
					type: "post",
					url:  "${ctx}/business/projectmanage/generateWord",
					data:top.$("#addProjectsDataForm").serialize(),
					success: function(data,res){
						var result = $.trim(res.responseText);
						if(result == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[result];
							if(msn != undefined){
								$.messager.alert('提示',msn,'info',function(){top.location='${ctx}/manage';});
								return ;
							}
						}
						$.messager.alert('提示',"生成成功！",'info');
						var result=eval("("+data+")");
						$.each(result,function(index,res){
							if(res.functionFlog==5){
								//$("#establishFile").attr("href","${ctx}/business/projectmanage/fileView?resId="+res.id);
								$("#establishFile").attr("href","javascript:showOpenFile('ctx','"+res.id+"','"+requestUrl+"');");
								$("#establishFile").html(res.oldName);
							}
						});
					},
					error: function(res){
						$.messager.alert('提示',i18n.requestError,'error');
					}
				});
		});



		$(function(){
			//需求清单
			
			$("#uploadify").uploadify({
				'height'        : 27,   
	            'width'         : 80,    
	            'buttonText'    : '选择附件',
	            'queueID': 'fileQueue',//队列的ID
	            'queueSizeLimit':5,// 附件附列长度
				'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
				'uploader':'${ctx}/business/projectmanage/upload;jsessionid=${pageContext.session.id}?functionFlog=8',// 上传时请求的后台处理的controller
				'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
				'method':'post',  
				'folder': '',
				'preventCaching' : true,
				'fileTypeExts' :'*.rar;*.zip;*.doc;*.docx;*.xls;*.xlsx;*.jpg;*.png;*.gif;*.bmp;*.pdf;*.dwg;*.DXF;*.DWT;*.dws',
				'auto': true,
				'multi': true,//是否可多选
				'removeCompleted' : false,
				'successTimeout' : 55555,
				'onUploadSuccess':function(file, data, response){
					$('#' + file.id).find('.data').html(' 上传完毕');
					$('#budgetMenuData').val($('#budgetMenuData').val() + "," + data);
					var cancel=$('#fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
					if (cancel) {
					   cancel.attr("rel", data);
					   cancel.click(function () {
						   var cancelData = cancel.attr("rel");
			               var  budgetMenuData = $('#budgetMenuData').val();
			               var index = budgetMenuData.indexOf(","+cancel.attr("rel"))
			               if(index != -1){
			            	   budgetMenuData = budgetMenuData.replace(","+cancelData,"");
			            	   $('#budgetMenuData').val(budgetMenuData);
			               }
					   });
					}
				},
				'onSelectError':function(file, errorCode, errorMsg){
					switch(errorCode) {
						case -110:
							//this.queueData.errorMsg="文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload').uploadify('settings','fileSizeLimit')+"大小！";
							this.queueData.errorMsg='所选文件大小超出系统限制!';
							break;
						case -120:
							//this.queueData.errorMsg="文件 ["+file.name+"] 大小异常！"
							this.queueData.errorMsg='所选文件大小异常!';
							break;
						case -130:
							//this.queueData.errorMsg="文件 ["+file.name+"] 类型不正确！"
							this.queueData.errorMsg='所选文件类型不正确!';
							break;
					}
				},
				'onCancel' : function(file){
					alert(file);
				}
			});
		});

		function deleteFile(v,resId){
			var parent = v.parentNode;
			parent.parentNode.removeChild(parent);
			var  budgetMenuData = $('#budgetMenuData').val();
	        var index = budgetMenuData.indexOf(","+resId)
	        if(index != -1){
	     	   budgetMenuData = budgetMenuData.replace(","+resId,"");
	     	   $('#budgetMenuData').val(budgetMenuData);
	        }

	        //删除数据库中的文件信息
	        $.ajax({
				type : "post",
				url : "${ctx}/business/projectmanage/deleteFile?resId="+resId,
				data : top.$("#addProjectsDataForm").serialize(),
				success : function(data){
					
				},
				error : function(data){
					alert("错误");
				}
			});
		}

		//确认截止时间与开标时间需间隔3天以上
		$.extend($.fn.validatebox.defaults.rules, {
			dateTimeMoreThreeCompare: {
				 validator: function (value, param) {
					var beginTime=$("input[name='validTime']").val();
					if(beginTime==""){
						beginTime=$('#validTime').datebox('getValue');
					}
					var end=new Date(beginTime.replace(/-/g,"/").substring(0,10));
					var beginDate = new Date(end.valueOf() + 1*24*60*60*1000);
					var endDate = new Date(value.replace(/-/g,"/"));
					//if(endDate.getDay()==1){//开标时间校验（不能为星期一）
						//return false;
					//}
					return endDate.getTime()-beginDate.getTime()>=259200000;//3天 259200000毫秒 
				 },
				 message: '确认截止时间与开标时间需间隔3天以上'
			 }
		 });
		
		//开标时间不能为星期一上午
		$.extend($.fn.validatebox.defaults.rules, {
			isMonAm: {
				 validator: function (value, param) {
					var bidStartDateStr=$("input[name='bidStartDateStr']").val();
					var beginTime=$("input[name='validTime']").val();
					if(beginTime==""){
						beginTime=$('#validTime').datebox('getValue');
					}
					var end=new Date(beginTime.replace(/-/g,"/").substring(0,10));
					var beginDate = new Date(end.valueOf() + 1*24*60*60*1000);
					var endDate = new Date(bidStartDateStr.replace(/-/g,"/"));
					if(endDate.getDay()==1&&value==09){//开标时间校验（不能为星期一）
						return false;
					}
					return true; 
				 },
				 message: '开标时间不能为星期一上午'
			 }
		 });
		
		//确认截止时间必须超过当前时间
		$.extend($.fn.validatebox.defaults.rules, {
			dateTimeMoreCurrentCompare: {
				 validator: function (value, param) {
					$('#validTime').val(value);
					var beginDate = new Date(value.replace(/-/g,"/"));
					var currentTime=new Date();
					var maxDate=new Date((myformatter(beginDate)+" 16:30:00").replace(/-/g,"/"));
					if(beginDate.getTime()>maxDate.getTime()){//确认时间不能迟于16:30
						return false;
					}
					
					return beginDate.getTime()>currentTime.getTime();
				 },
				 message: '确认截止时间必须超过当前时间,且不能迟于16:30'
			 }
		 });
		
		//供货时间必须超过当前时间
		$.extend($.fn.validatebox.defaults.rules, {
			dateTimeMoreCurrentDeliveryLimit: {
				 validator: function (value, param) {
					var beginDate = new Date(value.replace(/-/g,"/"));
					var currentTime=new Date();
					return beginDate.getTime()>currentTime.getTime();
				 },
				 message: '供货期限时间必须超过当前时间'
			 }
		 });

		/**
		* 获取当前时间
		*/
		function myformatter(date){  
		    var y = date.getFullYear();  
		    var m = date.getMonth()+1;  
		    var d = date.getDate();  
		    return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);  
		}  
		
		/**
		*格式化当前时间
		*/
		function myparser(s){  
		    if (!s) return new Date();  
		    var ss = (s.split('-'));  
		    var y = parseInt(ss[0],10);  
		    var m = parseInt(ss[1],10);  
		    var d = parseInt(ss[2],10);  
		    if (!isNaN(y) && !isNaN(m) && !isNaN(d)){  
		        return new Date(y,m-1,d);  
		    } else {  
		        return new Date();  
		    }  
		}  
		  
		//页面加载 
		$(function(){  
			//var fromTime=$("#qualifyFromDateStr").datebox("getValue");
			var socialSecurityBegin=$("#socialSecurityBeginTime").datebox("getValue");
			
			if(socialSecurityBegin==""){
				//初始化社保缴纳时间合同时间 
	 			var curr_time = new Date();
				$("#socialSecurityEndTime").datebox("setValue",myformatter(curr_time));  
	 			curr_time.setMonth(curr_time.getMonth() - 3);
				$("#socialSecurityBeginTime").datebox("setValue",myformatter(curr_time));  
			}
		});  
		
		 $("#parentProjCode").combobox({
			    required: false,
			    editable: true, 
			    missingMessage: '请输入',
			    valueField: "id",
			    textField: "text",
			    method: 'post',
			    url: '${ctx }/business/projectmanage/comboList',
			    mode: "local",
			    onHidePanel: onComboboxHidePanel,
			    filter: function (q, row) {
			      //定义当'mode'设置为'local'时如何过滤本地数据，函数有2个参数：
			      //q：用户输入的文本。
			      //row：列表行数据。
			      //返回true的时候允许行显示。
			      //return row[$(this).combobox('options').textField].indexOf(q) > -1;
			      return row["spell"].indexOf(q.toUpperCase()) >= 0;
			    }
			  });
		 
		 //开标时间选择事件
		  $('#bidStartDateStr').datebox({
	            onSelect: function (date) {
	            	//$("#bidStartTimeStr").empty();
	            	$('#bidStartTimeStr').combobox('setValues','');  
	            }
	        });
</script>

</html>

